Factions don't mind the player smashing zombie corpses #77426
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Balance "Factions don't mind the player smashing zombie corpses"
Purpose of change
Does not close the issue.
Describe the solution
Pre-check the target to see if there's a corpse that might end up getting smashed. Corpses are always smashed before terrain, so if there's a corpse we can't possibly smash terrain. Therefore, skip the warning (and possible relations loss).
This does technically iterate the target tile twice, which is slightly wasteful
Describe alternatives you've considered
I thought about passing the corpse smashing information along as an optional argument to avatar::smash() as a bool or container of item_location, to prevent the double iteration of the map tile.
I thought about refactoring smash() and avatar::smash() so target information is available before the checks for whether we should smash
But in the end I went with this. It could be unknowingly broken in the future if avatar::smash() changes the order of checks, but at worst it would produce a obviously-unintended exploit (e.g. being able to put a corpse on a tile and then bash the terrain). I think this possibility for breakage is a safer idea than refactoring which could introduce other bugs.
Testing
Smash left, then smash right
2024-10-29.00-44-58.mp4
Additional context